/*
 * @Description: 
 * @Version: 
 * @Company: 杭州凯立通信有限公司
 * @Author: Jesen
 * @Date: 2018-11-22 15:06:07
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2018-11-22 15:38:34
 */
import service from './ajax'
//restful API接口请求方式设置
let base = '';

export const postRequest = (url, params) => {
    return service({
        method: 'post',
        url: `${base}${url}`,
        data: params,
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
export const uploadFileRequest = (url, params) => {
    return service({
        method: 'post',
        url: `${base}${url}`,
        data: params,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    });
}
export const putRequest = (url, params) => {
    return service({
        method: 'put',
        url: `${base}${url}`,
        data: params,
        //transformRequest就是在axios发送数据之前对需要发的数据进行处理，可以在这里附加token和uid然后返回data。
        // transformRequest: [function(data) {
        //     let ret = ''
        //     for (let it in data) {
        //         ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
        //     }
        //     return ret
        // }],
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
export const deleteRequest = (url) => {
    return service({
        method: 'delete',
        url: `${base}${url}`
    });
}
export const getRequest = (url) => {
    return service({
        method: 'get',
        url: `${base}${url}`
    });
}
export const getRequestParams = (url, params) => {
    return service({
        method: 'get',
        url: `${base}${url}`,
        params: params
    });
}